home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / BORUSR2.ZIP;1 / PROC.PRG < prev    next >
Encoding:
Text File  |  1992-07-06  |  62.9 KB  |  1,637 lines

  1. *-- PROGRAM.....: PROC.PRG 
  2. ** Version of the PROC.PRG file from the soon to be released LIB16.ZIP set
  3. ** of procedure/library files. This has had several routines modified to
  4. ** take advantage of "explicit color setting" ... bypassing a known problem
  5. ** in dBASE IV, 1.5. Added the mouse drivers here, as well. 06/09/1992
  6. ** (A few more additions ... Jay's RECOLOR(), COLOROF(), my COLORBRK(), and
  7. ** Keith's VPICK() ... Joey's PROGBAR some nice stuff all on/around: 06/29/1992)
  8. *-------------------------------------------------------------------------------
  9. *-- Programmer..: Kenneth J. Mayer, (KENMAYER on BORBBS)
  10. *-- Date........: 06/29/1992
  11. *-- Version.....: 2.6  -- See WHATS.NEW and README.TXT files (both ASCII),
  12. *--               both files uploaded to BORBBS with this file in one
  13. *--               zipped file.
  14. *-- Notes.......: This procedure file is part of the new and improved set of
  15. *--               files, re-designed for dBASE IV, 1.7. The complete set is
  16. *--               contained in the file: LIB16.ZIP. Please read README.TXT
  17. *--               for all instructions.
  18. *===============================================================================
  19.  
  20. *===============================================================================
  21. * MESSAGE/SCREEN PROCESSING ROUTINES -- includes message boxes, shadowing,
  22. * and centering of text ... Anything not here is in the library file: 
  23. * SCREEN.PRG.
  24. *===============================================================================
  25.  
  26. PROCEDURE PrintErr
  27. *-------------------------------------------------------------------------------
  28. *-- Programmer..: Ken Mayer (KENMAYER)
  29. *-- Date........: 05/24/1991
  30. *-- Notes.......: Used to display a printer error for STAND-ALONE
  31. *--               systems. (The dBASE function PRINTSTATUS() doesn't work
  32. *--               well on a Network with Print Spoolers ...)
  33. *-- Written for.: dBASE IV, 1.1
  34. *-- Rev. History: None
  35. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  36. *--               CENTER               Procedure in PROC.PRG
  37. *-- Called by...: Any
  38. *-- Usage.......: do printerr
  39. *-- Example.....: do setprint  && if it hasn't been done
  40. *--               if .not. printstatus()
  41. *--                  DO PRINTERR
  42. *--               endif
  43. *--               *    or
  44. *--               do while .not. printstatus() && my preference ... loop!
  45. *--                  DO PRINTERR
  46. *--               enddo
  47. *-- Returns.....: None
  48. *-- Parameters..: None
  49. *-------------------------------------------------------------------------------
  50.  
  51.     private cColor, cDummy, cCursor
  52.     
  53.     if iscolor()    && if we're using a color monitor, use yellow on red
  54.         cColor = "RG+/R,RG+/R,RG+/R"
  55.     else            && otherwise, use black on white
  56.         cColor = "N/W,N/W,N/W"
  57.     endif
  58.     
  59.     define window wPErr from  7,15 to 16,57 double color &cColor
  60.     save screen to sPErr       && store current screen
  61.     do shadow with 7,15,16,57    && shadow box!
  62.     activate window wPErr      && here we go ..
  63.     
  64.     cCursor=set("CURSOR")      && save cursor setting
  65.     set cursor off             && turn cursor off
  66.                                && display message
  67.     do center with 0,40,"",chr(7) + "*** PRINTER ERROR ***"
  68.     do center with 2,40,""," The printer is not ready. Please check:"
  69.     do center with 3,40,"","1) that the printer is ON,        "
  70.     do center with 4,40,"","2) that the printer is ONLINE, and"
  71.     do center with 5,40,"","3) that the printer has paper.    "
  72.     do center with 7,40,"","Press any key to continue . . ."
  73.     
  74.     cDummy=inkey(0)            && wait for user to press a key ...
  75.     set cursor &cCursor        && set cursor to original setting ...
  76.     
  77.     deactivate window wPErr    && cleanup
  78.     release window wPErr
  79.     restore screen from sPErr
  80.     release screen sPErr
  81.     
  82. RETURN  
  83. *-- EoP: PrintErr
  84.  
  85. PROCEDURE Open_Screen
  86. *-------------------------------------------------------------------------------
  87. *-- Programmer..: Rick Price (HAMMETT)
  88. *-- Date........: 05/24/1991
  89. *-- Notes.......: Used to give a texture to the background of the screen
  90. *--               I got this from Rick when he uploaded it as part of his 
  91. *--               original entry to a Color Contest on the ATBBS. It is
  92. *--               kinda nice to have that texture on the screen, keeps it
  93. *--               from being monotonous.
  94. *-- Written for.: dBASE IV, 1.1
  95. *-- Rev. History: None
  96. *-- Calls.......: None
  97. *-- Called by...: Any
  98. *-- Usage.......: do open_screen
  99. *-- Example.....: do open_screen
  100. *-- Returns.....: None
  101. *-- Parameters..: None
  102. *-------------------------------------------------------------------------------
  103.  
  104.     private nRow, cBackDrp, nHoldRow
  105.     
  106.     clear
  107.     nRow=0
  108.     cBackdrp = chr(176)  && chr(176) = "∞", chr(177) = "±", chr(178) = "≤"
  109.     do while nRow < 3
  110.        @nRow,0 to nRow+3,79 cBackdrp  && fill this section of the screen
  111.        nHoldRow = nRow
  112.        nRow = nRow + 6
  113.        @nRow,0 to nRow+3,79 cBackdrp
  114.        nRow = nRow + 6
  115.        @nRow,0 to nRow+3,79 cBackdrp
  116.        nRow = nRow + 6
  117.        @nRow,0 to nRow+3,79 cBackdrp
  118.        nRow = nHoldRow + 1
  119.     enddo
  120.     @24,0 to 24,79 cBackdrp
  121.  
  122. RETURN
  123. *-- EoP: OpenScreen
  124.  
  125. PROCEDURE JazClear
  126. *-------------------------------------------------------------------------------
  127. *-- Programmer..: Rick Price (HAMMETT)
  128. *-- Date........: 05/24/1991
  129. *-- Notes.......: Used to clear the screen from the middle out --
  130. *--               could be used with OpenScreen, above. I got this
  131. *--               from Rick at the same time I got the other routine above ...
  132. *--               This requires a full screen (0,0 to 23,79 ...)
  133. *-- Written for.: dBASE IV, 1.1
  134. *-- Rev. History: None
  135. *-- Calls.......: None
  136. *-- Called by...: Any
  137. *-- Usage.......: do jazclear
  138. *-- Examples....: do jazclear
  139. *-- Returns.....: None
  140. *-- Parameters..: None
  141. *-------------------------------------------------------------------------------
  142.  
  143.     private nWinR1, nWinR2, nWinC1, nWinC2, nStep, mnWinC1, mnWinC2, ;
  144.             mnWinR1, mnWinR2, nStep, nTmpAdjR, nTmpAdjC, nAdjRow, nAdjCol
  145.     private nColLeft, nColRite, nRowTop, nRowBot
  146.     
  147.     nWinR1 = 0     && row 1
  148.     nWinR2 = 24  && row 2
  149.     nWinC1 = 0   && column 1
  150.     nWinC2 = 79  && column 2
  151.     nStep = 1    && amount to increment by
  152.       * set starting point
  153.     mnWinC1 = int((nWinC2-nWinC1)/2)+nWinC1
  154.     mnWinC2 = mnWinC1+1
  155.     mnWinR1 = int((nWinR2-nWinR1)/2)+nWinR1
  156.     mnWinR2 = mnWinR1+1
  157.     
  158.     ** Adjust step offset values: nColOff & nRowOff
  159.     ** Vertical steps: nWinR1-nWinR1
  160.     nTmpAdjR = int((nWinR2 - nWinR1)/2)
  161.     nTmpAdjC = int((nWinC2 - nWinC1)/2)
  162.     
  163.     nAdjRow = ;
  164.     iif(nTmpAdjC > nTmpAdjR, nTmpAdjR/nTmpAdjC,1) * nStep
  165.     
  166.     nAdjCol = ;
  167.     iif(nTmpAdjR > nTmpAdjC, nTmpAdjC/nTmpAdjR,1) * nStep
  168.     
  169.     ncolleft = nWinC1
  170.     ncolrite = nWinC2
  171.     nRowTop = nWinR1
  172.     nRowBot = nWinR2
  173.     nWinC1 = mnWinC1
  174.     nWinC2 = mnWinC2
  175.     nWinR1 = mnWinR1
  176.     nWinR2 = mnWinR2
  177.     do while (nWinC1#nColLeft .or. nWinC2#nColRite .or. ;
  178.         nWinR1 # nRowTop .or. nWinR2 # nRowBot)
  179.         
  180.         * Adjust coordinates for the clear (moving out from the middle)
  181.         nWinR1 = ;
  182.         nWinR1-iif(nRowTop<nWinR1-nAdjRow,nAdjRow,nWinR1-nRowTop)
  183.         nWinR2 = ;
  184.         nWinR2+iif(nRowBot>nWinR2+nAdjRow,nAdjRow,nRowBot-nWinR2)
  185.         nWinC1 = ;
  186.         nWinC1-iif(nColLeft<nWinC1-nAdjCol,nAdjCol,nWinC1-nColLeft)
  187.         nWinC2 = ;
  188.         nWinC2+iif(nColRite>nWinC2+nAdjCol,nAdjCol,nColRite-nWinC2)
  189.         
  190.         * Perform the clear
  191.         @nWinR1,nWinC1 clear to nWinR2,nWinC2
  192.         @nWinR1,nWinC1 to nWinR2,nWinC2
  193.     enddo
  194.     clear
  195.     
  196. RETURN   
  197. *-- EoP: JazClear
  198.  
  199. PROCEDURE Center
  200. *-------------------------------------------------------------------------------
  201. *-- Programmer..: Miriam Liskin
  202. *-- Date........: 05/24/1991
  203. *-- Notes.......: Centers text on the screen with @says
  204. *-- Written for.: dBASE IV, 1.1
  205. *-- Rev. History: This and all other procedures/functions listed in this
  206. *--               file attributed to Miriam Liskin came from "Liskin's
  207. *--               Programming dBASE IV Book". Very good, worth the money.
  208. *-- Calls.......: None
  209. *-- Called by...: Any
  210. *-- Usage.......: do center with <nLine>,<nWidth>,"<cColor>","<cText>"
  211. *-- Example.....: do center with 5,65,"RG+/GB","WARNING! This will blow up!"
  212. *--                  Note that the color field may be blank: ""
  213. *-- Returns.....: None
  214. *-- Parameters..: nLine  = Line or Row for @/Say
  215. *--               nWidth = Width of screen
  216. *--               cColor = Colors to be used ("Forg/Back") (may be nul "", in
  217. *--                           order to use the default colors of window/screen)
  218. *--               cText  = Message to center on screen
  219. *-------------------------------------------------------------------------------
  220.     
  221.     parameters nLine,nWidth,cColor,cText
  222.     private nCol
  223.     
  224.     nCol = (nWidth - len(cText)) /2
  225.     @nLine,nCol say cText color &cColor.
  226.     
  227. RETURN
  228. *-- EoP: Center
  229.  
  230. FUNCTION Surround
  231. *-------------------------------------------------------------------------------
  232. *-- Programmer..: Miriam Liskin
  233. *-- Date........: 05/24/1991
  234. *-- Notes.......: Displays a message surrounded by a box anywhere on 
  235. *--               the screen
  236. *-- Written for.: dBASE IV, 1.1
  237. *-- Rev. History: 04/19/1991 - Modified by Ken Mayer (KENMAYER) to a function
  238. *--               from original procedure
  239. *-- Calls.......: None
  240. *-- Called by...: Any
  241. *-- Usage.......: surround(<nLine>,<nColumn>,"<cColor>","<cText>")
  242. *-- Example.....: cDummy = surround(5,12,"RG+/GB",;
  243. *--                        "Processing ... Do not Touch!")
  244. *-- Returns.....: Nul/""
  245. *-- Parameters..: nLine   = Line to display "surrounded" message at
  246. *--               nColumn = Column for same (X,Y coordinates for @SAY)
  247. *--               cColor  = Color variable/colors
  248. *--               cText   = Text to be displayed inside box
  249. *-------------------------------------------------------------------------------
  250.     
  251.     parameters nLine,nColumn,cColor,cText
  252.     
  253.     cText = " " + trim(cText) + " "             && add spaces around text
  254.     @nLine-1,nColumn-1 to nLine+1,nColumn+len(cText) double;
  255.         color &cColor.                           && draw box
  256.     @nLine,nColumn say cText color &cColor.  && disp. text
  257.     
  258. RETURN "" 
  259. *-- EoF: Surround()
  260.  
  261. PROCEDURE ProgBar
  262. *-------------------------------------------------------------------------------
  263. *-- Programmer..: Joey D. Carroll (JOEY)
  264. *-- Date........: 06/28/1992
  265. *-- Notes.......: A visual indicator of program activity, i.e. shows
  266. *--               user program didn't die during long processes which
  267. *--               do not normally show 'on screen'.  Serves same purpose
  268. *--               as MONITOR, but is more graphic.
  269. *--               For best appearance, set cursor 'off' from calling
  270. *--               program, outside of the loop which calls PROGBAR.
  271. *-- Written for.: dBASE IV, 1.5
  272. *-- Rev. History: None
  273. *-- Calls.......: None
  274. *-- Called by...: Any
  275. *-- Usage.......: do PROGBAR with <nQuan>,<cWindCol>,<cFillCol1>,cFillCol2>, ;
  276. *--                   <cMessage>,<nWindWidth>
  277. *-- Example.....: *-- determine what process will be monitored and what the
  278. *--               *-- final value will be, e.g. nReccount = reccount()
  279. *--               use <anyfile>
  280. *--               nReccount = reccount()
  281. *--               set cursor off
  282. *--               scan
  283. *--                  do progbar with nReccount,",,w+/n","w+/r","w+/g", ;
  284. *--                     "Processing records.  Be patient.",40
  285. *--                  *-- do some needed process here
  286. *--               endscan
  287. *--               *-- cleanup
  288. *-- Returns.....: None
  289. *-- Parameters..: nQuan     = maximum number of iterations
  290. *--               cWindCol  = the window colors
  291. *--               cFillCol1 = color of ruler before process
  292. *--               cFillCol2 = color of ruler after process
  293. *--               cMessage  = message displayed to user, may be "".
  294. *--               nWindWid  = (optional) desired width of ruler window.  If
  295. *--                               not specified, width of screen.  If
  296. *--                               specified, will not be less than length of
  297. *--                               message.
  298. *-------------------------------------------------------------------------------
  299.  
  300.    parameters nQuan,cWindCol,cFillCol1,cFillCol2,cMessage,nWindWidth
  301.    private lMessage,x
  302.    lMessage  = iif(.not. isblank(cMessage), .t., .f.)  && was message passed?
  303.     *-- find out # of parameters passed ...
  304.     if val(right(version(),3)) > 1.1
  305.         nParms = pcount()
  306.     else
  307.         nParms = 6
  308.     endif
  309.    nWindWidth = iif(nParms = 6,nWindWidth,78) && all the way if width not passed
  310.    nWindWidth = min(nWindWidth,78)            && width param > 78 not allowed
  311.    *-- window width can't be narrower than messsage, so....
  312.    nWindWidth = iif(lMessage,max(nWindWidth,len(cMessage) + 2),nWindWidth)
  313.    *-- skip this section if we've been here before
  314.    *-- this procedure called from inside a loop
  315.    *-- following section ignored except on first iteration thru loop
  316.    if type("nTimes") = "U"  && check to see if we been here before
  317.       save screen to sProgBar
  318.       public nFactor,nTimes  && make these available on all iterations
  319.       nProgLine = iif(set("status") = "ON",20,22)  && don't overwrite status
  320.       *-- determine how wide the window needs to be
  321.       define window wProgBar from ;
  322.          nProgLine - iif(lMessage, 2, 1),(80 - (nWindWidth + 2)) / 2 ;
  323.          to nProgLine + 1,(80 + (nWindWidth + 2)) / 2 - 1 ;
  324.          double color &cWindCol
  325.       activate window wProgBar
  326.       @ 0,0 say replicate(".",nWindWidth - 1)  && the ruler
  327.       @ 0,0 say "0%"                        && and some gradation %'s
  328.       @ 0,nWindWidth / 4 - 2 say "25%"
  329.       @ 0,nWindWidth / 2 - 2 say "50%"
  330.       @ 0,3*(nWindWidth / 4) - 2 say "75%"
  331.       @ 0,nWindWidth - 4 say "100%"
  332.       @ 0,0 fill to 0,nWindWidth - 1 color &cFillCol1  && color of ruler before process
  333.       if lMessage
  334.          @ 1,(nWindWidth - (len(cMessage))) / 2 say cMessage color &cFillCol1
  335.          @ 1,0 fill to 1,nWindWidth - 1 color &cFillCol1
  336.       endif
  337.       nFactor = nQuan/nWindWidth   && e.g. how many records per bar part(cols)
  338.       nTimes = 0  && times thru loop
  339.    endif      && type("nTimes") = "U"
  340.  
  341.    *-- this section will be processed as many times as required by nQuan
  342.    nTimes = nTimes + 1
  343.    @ 0,0 fill to 0,int(nTimes / nFactor) ;
  344.          - iif(int(nTimes / nFactor) - 1 >= 0, 1, 0) ;
  345.          color &cFillCol2    && color of ruler as processing takes place
  346.    if nTimes = nQuan  && we done
  347.       x = inkey(.5)   && leave on screen just a liitle while after completion
  348.       *-- cleanup your mess
  349.       deactivate window wProgBar
  350.       release window wProgBar
  351.       restore screen from sProgBar
  352.       release screen sProgBar
  353.       release nProgBar,nFactor,nTimes,lMessage,x
  354.    endif  && nTimes = nQuan
  355. RETURN
  356. *-- EoP: ProgBar
  357.  
  358. FUNCTION ScrnHead
  359. *-------------------------------------------------------------------------------
  360. *-- Programmer..: Miriam Liskin
  361. *-- Date........: 05/23/1991
  362. *-- Notes.......: Displays a heading on the screen in a box 2 
  363. *--               spaces wider than the text, with a custom border (double 
  364. *--               line top, single the rest)
  365. *-- Written for.: dBASE IV, 1.1
  366. *-- Rev. History: 4/29/1991 - Modified by Ken Mayer (KENMAYER) to add shadow
  367. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  368. *-- Called by...: Any
  369. *-- Usage.......: scrnhead("<cColor>","<cText>")
  370. *-- Examples....: cDummy = ScrnHead("rg+/gb","Print Financial Report")
  371. *-- Returns.....: nul/""
  372. *-- Parameters..: cColor = Colors to display box/text in
  373. *--               cText  = text to be displayed.
  374. *-------------------------------------------------------------------------------
  375.  
  376.     parameters cColor,cText
  377.     private cTextStart,cText2
  378.     
  379.     cText2 = " "+trim(cText)+" "             && ad spaces to left and right
  380.     cTextstart = (80-len(trim(cText2)))/2
  381.     do shadow with 1,cTextstart-1,3,81-cTextstart
  382.     @1,cTextstart-1 to 3,81-cTextstart 205,196,179,179,213,184,192,217;
  383.         color &cColor.                           && display box
  384.     @2, cTextstart say cText2 color &cColor. && display text
  385.  
  386. RETURN ""
  387. *-- EoF: ScrnHead()
  388.  
  389. FUNCTION YesNo
  390. *-------------------------------------------------------------------------------
  391. *-- Programmer..: Miriam Liskin
  392. *-- Date........: 06/08/1992
  393. *-- Notes.......: Asks a yes/no question in a dialog window/box
  394. *-- Written for.: dBASE IV, 1.1
  395. *-- Rev. History: 04/19/1991 - Modified by Ken Mayer to become a function
  396. *--               04/29/1991 - Modified by Ken Mayer add shadow
  397. *--               05/13/1991 - Modified by Ken Mayer remove need for extra 
  398. *--                            procedures (YES/NO) that were used for returning
  399. *--                            values from Menu
  400. *--                            (suggested by Clinton L. Warren (VBCES))
  401. *--               01/20/1992 - Modified by Martin Leon (HMan) to handle user
  402. *--                            pressing 'Y' or 'N' keys (with ON KEY ...).
  403. *--               04/22/1992 - Modified by Ken Mayer adding CLEAR TYPEAHEAD,
  404. *--                            as occaisional problems appear otherwise.
  405. *--               06/08/1992 - Modified (Ken Mayer) to deal with explicit
  406. *--                            color processing.
  407. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  408. *--               CENTER               Procedure in PROC.PRG
  409. *--               RECOLOR              Procedure in PROC.PRG
  410. *--               COLORBRK()           Function in PROC.PRG
  411. *-- Called by...: Any
  412. *-- Usage.......: yesno(<lAnswer>,"<cMess1>","<cMess2>","<cMess3>","<cColor>")
  413. *-- Example.....: if YesNo(.t.,"Do You Really Wish To Delete?",;
  414. *--                            "This will destroy the data";
  415. *--                             "in this record.";
  416. *--                             "rg+/gb,n/w,rg+/gb")
  417. *--                  delete
  418. *--               else
  419. *--                  skip
  420. *--               endif
  421. *--
  422. *--                 The middle set of colors should be different, as they
  423. *--                 will be the colors of the YES/NO selections ...
  424. *--                 Options may be blank by using nul values ("")
  425. *-- Returns.....: .t./.f. depending on user's choice from menu
  426. *-- Parameters..: lAnswer = default value (Yes or No) for menu
  427. *--               cMess1  =  First line of Message
  428. *--               cMess2  =  Second line of message
  429. *--               cMess3  =  Third line of message
  430. *--               cColor  =  Colors for window/menu/box
  431. *-------------------------------------------------------------------------------
  432.  
  433.     parameter lAnswer,cMess1,cMess2,cMess3,cColor
  434.     private nLMargin,nRMargin,lWrap,cCurColor,cTempCol
  435.     
  436.     *-- save old colors, and set new ones
  437.     cCurColor = set("ATTRIBUTES")
  438.     cTempCol = colorbrk(cColor,1)
  439.     set color of normal to &cTempCol
  440.     set color of message to &cTempCol
  441.     cTempCol = colorbrk(cColor,2)
  442.     set color of highlight to &cTempCol
  443.     cTempCol = colorbrk(cColor,3)
  444.     set color of box to &cTempCol
  445.     
  446.     save screen to sYesno
  447.     define window wYesno from 8,20 to 15,60 double 
  448.     
  449.     define menu mYesno
  450.     *-- remove && from MESSAGE option if using or might be used on Mono system
  451.     define pad pYes of mYesno Prompt "[Yes]" at 5,10 && message "Yes"
  452.     define pad pNo  of mYesno Prompt "[No]"  at 5,25 && message "No"
  453.     on selection pad pYes of mYesno deactivate menu
  454.     on selection pad pNo  of mYesno deactivate menu
  455.     
  456.     do shadow with 8,20,15,60
  457.     activate window wYesno
  458.     nLmargin = _lmargin    && store system values
  459.     nRmargin = _rmargin
  460.     lWrap    = _wrap
  461.     _lmargin   = 2            && set local values
  462.     _rmargin   = 38
  463.     _wrap      = .t.
  464.     
  465.     do center with 0,38,"",cMess1        && center the text
  466.     do center with 2,38,"",cMess2
  467.     do center with 3,38,"",cMess3
  468.  
  469.     *-- deal with user pressing 'Y' or 'N' ...
  470.    on key label Y keyboard IIF( PAD() = "PYES", "", CHR(19) )+chr(13)
  471.    on key label N keyboard IIF( PAD() = "PNO",  "", CHR(4)  )+chr(13)
  472.     *-- otherwise deal with regular "menu" abilities
  473.     clear typeahead
  474.    if lAnswer
  475.         activate menu mYesno pad pYes
  476.     else
  477.         activate menu mYesno pad pNo
  478.     endif
  479.     
  480.     *-- clear out ON KEY settings ...
  481.    on key label Y
  482.    on key label N
  483.     _lmargin = nLmargin    && reset system values
  484.     _rmargin = nRmargin
  485.     _wrap    = lWrap
  486.     deactivate window wYesno
  487.     release window wYesno
  488.     restore screen from sYesno
  489.     release screen sYesno
  490.     release menu mYesno
  491.     *-- reset colors
  492.     do ReColor with cCurColor
  493.  
  494. RETURN iif(pad()="PYES",.t.,.f.)
  495. *-- EoF: YesNo()
  496.  
  497. FUNCTION YesNo2
  498. *-------------------------------------------------------------------------------
  499. *-- Programmer..: Miriam Liskin
  500. *-- Date........: 06/08/1992
  501. *-- Notes.......: Asks a yes/no question in a dialog window/box
  502. *-- Written for.: dBASE IV, 1.1
  503. *-- Rev. History: 04/19/1991 - Modified by Ken Mayer to become a function
  504. *--               04/29/1991 - Modified by Ken Mayer add shadow
  505. *--               05/13/1991 - Modified by Ken Mayer remove need for extra 
  506. *--                            procedures (YES/NO) that were used for returning
  507. *--                            values from Menu
  508. *--                            (suggested by Clinton L. Warren (VBCES))
  509. *--               11/15/1991 - Copied YesNo, modified to allow "location" 
  510. *--                            options -- useful for some screens ...
  511. *--               01/20/1992 - Modified by Martin Leon (HMAN) to allow user to
  512. *--                            press 'Y' or 'N' and have them recognized ...
  513. *--               04/22/1992 - Modified by Ken Mayer adding CLEAR TYPEAHEAD,
  514. *--                            as occaisional problems appear otherwise.
  515. *--               06/08/1992 - Modified by same for explicit color sets.
  516. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  517. *--               CENTER               Procedure in PROC.PRG
  518. *--               COLOROF()            Function in PROC.PRG
  519. *--               COLORBRK()           Function in PROC.PRG
  520. *-- Called by...: Any
  521. *-- Usage.......: yesno2(<lAnswer>,"<cWhere>",;
  522. *--                                "<cMess1>","<cMess2>","<cMess3>","<cColor>")
  523. *-- Example.....: if YesNo2(.t.,"UL","Do You Really Wish To Delete?",;
  524. *--                            "This will destroy the data";
  525. *--                             "in this record.";
  526. *--                             "rg+/gb,n/w,rg+/gb")
  527. *--                  delete
  528. *--               else
  529. *--                  skip
  530. *--               endif
  531. *--
  532. *--                 The middle set of colors should be different, as they
  533. *--                 will be the colors of the YES/NO selections ...
  534. *--                 Options may be blank by using nul values ("")
  535. *-- Returns.....: .t./.f. depending on user's choice from menu
  536. *-- Parameters..: lAnswer = default value (Yes or No) for menu
  537. *--               cWhere  = location on screen:
  538. *--                            "UL" = Upper Left
  539. *--                            "UC" = Upper Center
  540. *--                            "UR" = Upper Right
  541. *--                            "CL" = Center Left
  542. *--                            "CC" = Center Center
  543. *--                            "CR" = Center Right
  544. *--                            "BL" = Bottom Left
  545. *--                            "BC" = Bottom Center
  546. *--                            "BR" = Bottom Right
  547. *--               cMess1  =  First line of Message
  548. *--               cMess2  =  Second line of message (may be nul = "")
  549. *--               cMess3  =  Third line of message  (may be nul = "")
  550. *--               cColor  =  Colors for window/menu/box
  551. *-------------------------------------------------------------------------------
  552.  
  553.     parameter lAnswer,cWhere,cMess1,cMess2,cMess3,cColor
  554.     private cExact,cW1,cW2,nULB,nBRR,nULC,nBRC,nLMargin,nRMargin,lWrap,;
  555.         cCurColor,cTempCol
  556.         
  557.     cExact = set("EXACT")
  558.     save screen to sYesno
  559.     *-- see what the user gave us ...
  560.     if len(trim(cWhere)) > 0
  561.         cW1 = upper(left(cWhere,1))  && first coordinate (vertical)
  562.         cW2 = upper(right(cWhere,1)) && second coordinate (horizontal)
  563.     else
  564.         cW1 = "C"
  565.         cW2 = "C"
  566.     endif
  567.     *-- deal with vertical placement
  568.     do case
  569.         case cW1 = "U"
  570.             nULR =  1   && upper left row
  571.             nBRR =  8   && bottom right row
  572.         case cW1 = "C"
  573.             nULR =  8
  574.             nBRR = 15
  575.         case cW1 = "B"
  576.             nULR = 15
  577.             nBRR = 22
  578.     endcase
  579.     *-- deal with horizontal placement
  580.     do case
  581.         case cW2 = "L"
  582.             nULC =  5   && upper left column
  583.             nBRC = 45   && bottom right column
  584.         case cW2 = "R"
  585.             nULC = 35
  586.             nBRC = 75
  587.         case cW2 = "C"
  588.             nULC = 20
  589.             nBRC = 60
  590.     endcase
  591.     
  592.     *-- save old colors, and set new ones
  593.     cCurColor = set("ATTRIBUTES")
  594.     cTempCol = colorbrk(cColor,1)
  595.     set color of normal to &cTempCol
  596.     set color of message to &cTempCol
  597.     cTempCol = colorbrk(cColor,2)
  598.     set color of highlight to &cTempCol
  599.     cTempCol = colorbrk(cColor,3)
  600.     set color of box to &cTempCol
  601.     
  602.     define window wYesno from nULR,nULC to nBRR,nBRC double 
  603.     
  604.     define menu mYesno
  605.     *-- remove && from MESSAGE option if using or might be used on Mono system
  606.     define pad pYes of mYesno Prompt "[Yes]" at 5,10 && message "Yes"
  607.     define pad pNo  of mYesno Prompt "[No]"  at 5,25 && message "No"
  608.     on selection pad pYes of mYesno deactivate menu
  609.     on selection pad pNo  of mYesno deactivate menu
  610.     *-- start displaying it ... shadow, window ...
  611.     do shadow with nULR,nULC,nBRR,nBRC
  612.     activate window wYesno
  613.     *-- store or set some system values
  614.     nLmargin = _lmargin    
  615.     nRmargin = _rmargin
  616.     lWrap    = _wrap
  617.     _lmargin   = 2            && set local values
  618.     _rmargin   = 38
  619.     _wrap      = .t.
  620.     *-- display text
  621.     do center with 0,38,"",cMess1        && center the text
  622.     do center with 2,38,"",cMess2
  623.     do center with 3,38,"",cMess3
  624.     *-- set 'y' or 'n' keys ...
  625.    on key label Y keyboard IIF( PAD() = "PYES", "", CHR(19) )+chr(13)
  626.    on key label N keyboard IIF( PAD() = "PNO",  "", CHR(4)  )+chr(13)
  627.     clear typeahead
  628.    if lAnswer
  629.         activate menu mYesno pad pYes
  630.     else
  631.         activate menu mYesno pad pNo
  632.     endif
  633.    
  634.     *-- reset system ...
  635.     on key label Y
  636.    on key label N
  637.     _lmargin = nLmargin
  638.     _rmargin = nRmargin
  639.     _wrap    = lWrap
  640.     deactivate window wYesno
  641.     release window wYesno
  642.     restore screen from sYesno
  643.     release screen sYesno
  644.     release menu mYesno
  645.     set exact &cExact
  646.     do ReColor with cCurColor
  647.  
  648. RETURN iif(pad()="PYES",.t.,.f.)
  649. *-- EoF: YesNo2()
  650.  
  651. FUNCTION ErrorMsg
  652. *-------------------------------------------------------------------------------
  653. *-- Programmer..: Ken Mayer (KENMAYER)
  654. *-- Date........: 05/23/1991
  655. *-- Notes.......: Display an error message in a Window: 
  656. *--                           ** ERROR [#] **
  657. *--
  658. *--                              Message 1
  659. *--                              Message 2
  660. *--                       Press any key to continue ...
  661. *-- Written for.: dBASE IV, 1.1
  662. *-- Rev. History: None
  663. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  664. *--               CENTER               Procedure in PROC.PRG
  665. *--               ALLTRIM()            Function in PROC.PRG
  666. *--               COLORBRK()           Function in PROC.PRG
  667. *--               RECOLOR              Procedure in PROC.PRG
  668. *-- Called by...: Any
  669. *-- Usage.......: ErrorMsg("<cErr>","<cMess1>","<cMess2>","<cColor>")
  670. *-- Example.....: lc_Dummy = errormsg("3","This record","already exists!",;
  671. *--                   "rg+/r,rg+/r,rg+/r")
  672. *--               where "errornum" is an error number or nul,
  673. *--               message2 and 3 should be 36 characters or less ...
  674. *--               Colors should include foreground/background,;
  675. *--                 foreground/background,foreground/background
  676. *-- Returns.....: numeric value of keystroke user presses (cUser)
  677. *-- Parameters..: cErr   = Error # (can be blank, but use "" for blank)
  678. *--               cMess1 = Error message line 1
  679. *--               cMess2 = Error message line 2
  680. *--               cColor = Colors for text/window/border
  681. *-------------------------------------------------------------------------------
  682.     
  683.     parameters cErr,cMess1,cMess2,cColor
  684.     private cCursor,cUser,cTempCol,cCurColor
  685.     
  686.     save screen to sErr
  687.     *-- save colors, set new ones
  688.     cCurColor = set("ATTRIBUTES")
  689.     cTempCol = colorbrk(cColor,1)
  690.     set color of normal to &cTempCol
  691.     cTempCol = colorbrk(cColor,3)
  692.     set color of box to &cTempCol
  693.     define window wErr from 8,20 to 15,60 double color &cColor
  694.     do shadow with 8,20,15,60
  695.     activate window wErr
  696.     
  697.     cCursor = set("CURSOR")
  698.     set cursor off
  699.     if len(trim(cErr)) > 0  && if there's an error number ...
  700.         do center with 0,38,"","** ERROR "+alltrim(cErr)+" **"
  701.     else                      && otherwise, don't display errornumber
  702.         do center with 0,38,"","** ERROR **"
  703.     endif
  704.     do center with 2,38,"",cMess1
  705.     do center with 3,38,"",cMess2
  706.     do center with 5,38,"","Press any key to continue ..."
  707.     cUser=inkey(0)
  708.     
  709.     set cursor &cCursor
  710.     deactivate window wErr
  711.     release window wErr
  712.     restore screen from sErr
  713.     release screen sErr
  714.     *-- reset colors
  715.     do ReColor with cCurColor
  716.     
  717. RETURN cUser
  718. *-- EoF: ErrorMsg()
  719.  
  720. PROCEDURE Shadow
  721. *-------------------------------------------------------------------------------
  722. *-- Programmer..: Ashton-Tate
  723. *-- Date........: 01/27/1992
  724. *-- Notes.......: Creates a shadow for a window (taken from the dBASE IV
  725. *--               picklist functions)
  726. *-- Written for.: dBASE IV, 1.1
  727. *-- Rev. History: 05/23/1991 - original procedure.
  728. *--               12/14/1991 - Modified by Jim Magnant (TXAGGIE) - to check
  729. *--               for columns exceeding 79, and temporarily change last col.
  730. *--               value (so routine doesn't "blow up").
  731. *--               01/27/1992 -- Modifiedy by Ken Mayer to check for bottom
  732. *--               of screen, based on what Jim did above. No further than 23.
  733. *-- Calls.......: None
  734. *-- Called by...: Too many to list ...
  735. *-- Usage.......: do shadow with <nULRow>,<nULCol>,<nBRRow>,<nBRCol>
  736. *-- Example.....: save screen to sMain
  737. *--               define window wError from 5,15 to 15,65 double color;
  738. *--                    rg+/r,rg+/r,rg+/r
  739. *--               do shadow with 5,15,15,65
  740. *--               activate window WError
  741. *--                && perform actions in window
  742. *--               deactivate window WError
  743. *--               release window WError
  744. *--               restore screen from sMain
  745. *--               release screen sMain
  746. *-- Returns.....: None
  747. *-- Parameters..: nULRow = Upper Left Row position
  748. *--               nULCol = Upper Left Column position (x,y)
  749. *--               nBRRow = Bottom Right Row position
  750. *--               nBRCol = Bottom Right Column position (x2,y2)
  751. *-------------------------------------------------------------------------------
  752.  
  753.     parameters nULRow,nULCol,nBRRow,nBRCOL
  754.     private nTempRow,nTempCol,nIncRow,nIncCol
  755.  
  756.     nTempRow = iif(nBRRow+1>23,23,nBRRow+1)
  757.     nTempCol = iif(nBRCol+2>79,79,nBRCol+2)
  758.     nIncRow = 1
  759.     nIncCol = (nBRCol-nULCol) / (nBRRow-nULRow)
  760.     do while nTempRow <> nULRow .or. nTempCol <> nULCol+2
  761.         nRightCol = nBRCol
  762.         nBRCol = iif(nBRCol + 2 > 79,77,nBRCol)
  763.         nBotRow = nBRRow
  764.         nBRRow = iif(nBRRow + 1 > 23,22,nBRRow)
  765.         @ nTempRow,nTempCol fill to nBRRow+1,nBRCol+2 color n+/n
  766.         nBRCol = nRightCol
  767.         nBRRow = nBotRow
  768.         nTempRow = iif(nTempRow<>nULRow,nTempRow - nIncRow,nTempRow)
  769.         nTempCol = iif(nTempCol<>nULCol+2,nTempCol - nIncCol,nTempCol)
  770.         nTempCol = iif(nTempCol<nULCol+2,nULCol+2,nTempCol)
  771.     enddo
  772.     
  773. RETURN
  774. *-- EoP: Shadow
  775.  
  776. *===============================================================================
  777. * COLOR PROCESSING -- These routines handle setting colors, dealing with
  778. * checking how colors are set, and so on. Anything that's not here is in
  779. * the library file:  COLOR.PRG.
  780. *===============================================================================
  781.  
  782. FUNCTION ExtrClr
  783. *-------------------------------------------------------------------------------
  784. *-- Programmer..: Ken Mayer (KENMAYER)
  785. *-- Date........: 05/24/1991
  786. *-- Notes.......: Used to extract the first parameter of the MEMVARS
  787. *--               created from SETCOLOR above. The SET COLOR OF commands can
  788. *--               only use the first parameter.
  789. *--               It is recommended that you run SetColor (above) first, 
  790. *--               although if you define your own color memvars, this will work
  791. *--               just as well.
  792. *-- Written for.: dBASE IV, 1.1
  793. *-- Rev. History: None
  794. *-- Calls.......: None
  795. *-- Called by...: Any
  796. *-- Usage.......: extrclr(<cMemVar>)
  797. *-- Example.....: set color of highlight to &extrclr(cl_stand)
  798. *-- Returns.....: "W+/B"
  799. *-- Parameters..: cMemVar = color memory variable to have colors extracted from
  800. *-------------------------------------------------------------------------------
  801.     
  802.     parameters cMemVar
  803.     
  804. RETURN substr(cMemVar,1,(at(",",cMemVar)-1)) 
  805. *-- EoF: ExtrClr()
  806.  
  807. FUNCTION InvClr
  808. *-------------------------------------------------------------------------------
  809. *-- Programmer..: Ken Mayer (KENMAYER)
  810. *-- Date........: 05/23/1991
  811. *-- Notes.......: Used to set an inverse color, using value(s) returned
  812. *--               from extrclr above, or from a single color memvar.
  813. *--               Inverted colors may give odd results -- RG+ (yellow) is
  814. *--               not a background color, for example, and will appear as
  815. *--               RG (brown) -- this may not be what you wanted ...
  816. *-- Written for.: dBASE IV, 1.1
  817. *-- Rev. History: None
  818. *-- Calls.......: None
  819. *-- Called by...: Any
  820. *-- Usage.......: invclr(<cMemVar>)
  821. *-- Example.....: set color of highlight to &invclr(extrclr(cl_stand))
  822. *--                    or
  823. *--               x = extrclr(cl_stand)
  824. *--               set color of highlight to &invclr(x)
  825. *-- Returns.....: "B/W+"
  826. *-- Parameters..: cMemVar = color variable containing colors to be inverted
  827. *-------------------------------------------------------------------------------
  828.  
  829.     parameters cMemVar
  830.     private cTemp1, cTemp2
  831.     
  832.         cTemp1 = substr(cMemVar,1,(at("/",cMemVar)-1))
  833.         cTemp2 = substr(cMemVar,(at("/",cMemVar)+1),len(cMemVar))
  834.  
  835. RETURN cTemp2+"/"+cTemp1
  836. *-- EoF: InvClr()
  837.  
  838. FUNCTION ColorOf
  839. *-------------------------------------------------------------------------------
  840. *-- Programmer..: Jay Parsons (JPARSONS)
  841. *-- Date........: 01/11/1992
  842. *-- Notes.......: This function will return the color of a specified area
  843. *--               (as built in to dBASE). 
  844. *-- Written for.: dBASE IV, 1.1
  845. *-- Rev. History: None
  846. *-- Calls.......: ALLTRIM()            Function in PROC.PRG
  847. *-- Called by...: Any
  848. *-- Usage.......: ColorOf("<cArea>")
  849. *-- Example.....: ?ColorOf("Messages")
  850. *-- Returns.....: Color (foreground/background)
  851. *-- Parameters..: cArea = Area you wish to return the color of from list:
  852. *--               BOX/BOXES        = Boxes
  853. *--               BORDER/PERIMETER = Border color
  854. *--               NORMAL           = Normal screen/text
  855. *--               HIGHLIGHT        = Highlights
  856. *--               MESSAGE          = Messages
  857. *--               TITLE            = Titles
  858. *--               INFORMATION      = Information
  859. *--               FIELDS           = Fields
  860. *-------------------------------------------------------------------------------
  861.  
  862.     parameters cArea
  863.     
  864.     private cAttrib, cWanted, nPos
  865.     
  866.     cAttrib = set("ATTRIBUTES")
  867.     cWanted = upper(alltrim(cArea))
  868.     
  869.     if cWanted = "BOX"
  870.         nPos = 6
  871.     else
  872.         nPos = at(left(cWanted,4),;
  873.             "    NORM HIGH PERI MESS TITL BOXE INFO FIEL BORD") / 5
  874.         if nPos = 9
  875.             nPos = 3    && "Border" = "Perimeter"
  876.         endif
  877.     endif
  878.     
  879.     do case
  880.         case nPos = 0
  881.             cAttrib = ""  && return null string for error
  882.         case nPos < 4
  883.             cAttrib = left(cAttrib,at("&",cAttrib) - 2)
  884.         otherwise
  885.             cAttrib = substr(cAttrib,at("&",cAttrib) + 3)
  886.             nPos = nPos - 3
  887.     endcase
  888.     do while nPos > 1
  889.         cAttrib = substr(cAttrib,at(",",cAttrib) + 1)
  890.         nPos = nPos - 1
  891.     enddo
  892.     
  893. RETURN left(cAttrib,at(",",cAttrib+",")-1)
  894. *-- EoF: ColorOf()
  895.  
  896. PROCEDURE ReColor
  897. *-------------------------------------------------------------------------------
  898. *-- Programmer..: Jay Parsons (Jparsons)
  899. *-- Date........: 04/23/1992
  900. *-- Notes.......: Restores colors to those held in a string of the form
  901. *--               returned by set("ATTRIBUTE").
  902. *-- Written for.: dBASE IV, Versions 1.0 - 1.5.
  903. *-- Rev. History: None
  904. *-- Calls       : None
  905. *-- Called by...: Any
  906. *-- Usage.......: DO ReColor WITH <cColors>
  907. *-- Example.....: DO Recolor WITH OldColors
  908. *-- Parameters..: cColors, a string in the form returned by set("ATTRIBUTE").
  909. *-- Side effects: Changes the screen colors.
  910. *-------------------------------------------------------------------------------
  911.  
  912.   parameters cColors
  913.   private cThis, cNext, nAt, cLeft, nX, cAreas
  914.   cAreas = "   NORMHIGHBORDMESSTITLBOX INFOFIEL"
  915.   cLeft = cColors + ", "
  916.   nX = 0
  917.   do while nX < 8
  918.     nX = nX + 1
  919.     cThis = substr( cAreas, 4 * nX, 4 )
  920.     if nX = 3
  921.       nAt = at( "&", cLeft )
  922.       cNext = left( cLeft, nAt - 2 )
  923.       cLeft = substr( cLeft, nAt + 3 )
  924.       SET COLOR TO , , &cNext
  925.     else
  926.       nAt = at( ",", cLeft )
  927.       cNext = left( cLeft, nAt - 1 )
  928.       cLeft = substr( cLeft, nAt + 1 )
  929.       SET COLOR OF &cThis TO &cNext
  930.     endif
  931.   enddo
  932.  
  933. RETURN
  934. *-- EoP: ReColor
  935.  
  936. FUNCTION ColorBrk
  937. *-------------------------------------------------------------------------------
  938. *-- Programmer..: Ken Mayer (KENMAYER)
  939. *-- Date........: 06/08/1992
  940. *-- Notes.......: This routine is designed to be used with any of my functions
  941. *--               and procedures that accept a memory variable for color,
  942. *--               and use a window. It's purpose is to break that color var
  943. *--               into it's components (depending on which one the user wants)
  944. *--               and return those components, so that they can then be used
  945. *--               in SET COLOR OF ... commands.
  946. *-- Written for.: dBASE IV, 1.1, 1.5 (written because of 1.5, but will work in
  947. *--                1.1)
  948. *-- Rev. History: None
  949. *-- Calls.......: None
  950. *-- Called by...: Any
  951. *-- Usage.......: ColorBrk(<cColorVar>,<nField>)
  952. *-- Example.....: set color of normal to ColorBrk(cColor,1)
  953. *-- Returns.....: Either the field you asked for (1 thru 3) or null string ("").
  954. *-- Parameters..: cColorVar = Color variable to extract data from
  955. *--               nField    = Field you want to extract
  956. *-------------------------------------------------------------------------------
  957.  
  958.     parameters cColorVar, nField
  959.     private cReturn, cExtracted
  960.     
  961.     do case
  962.         case nField = 1
  963.             cReturn = left(cColorVar,at(",",cColorVar)-1)
  964.         case nField = 2
  965.             cExtract = substr(cColorVar,at(",",cColorVar)+1)  && everything to 
  966.                                                               && right of comma
  967.             cReturn = left(cExtract,at(",",cExtract)-1)       && left of second ,
  968.         case nField = 3
  969.             cExtract = substr(cColorVar,at(",",cColorVar)+1)
  970.             cReturn = substr(cExtract,at(",",cExtract)+1)
  971.         otherwise
  972.             cReturn = ""
  973.     endcase
  974.  
  975. RETURN cReturn
  976. *-- EoF: ColorBrk()
  977.  
  978. Function VPICK
  979. *-------------------------------------------------------------------------------
  980. *-- Programmer...: Keith G. Chuvala (KGC)
  981. *-- Date.........: 06/02/1992
  982. *-- Notes........: Keith wanted a multiple choice picklist routine for use
  983. *--                with a mouse (or other) ... he got the idea for the AT-USER
  984. *--                system which he was Beta Testing. Here 'tis ...
  985. *--                 This creates a quick pick-list for multiple-choice, single-
  986. *--                 character input. The first letter of the selected bar is
  987. *--                 returned. If <Esc> is pressed, a null string is returned.
  988. *--                NOTE: If using this with dBASE IV, 1.1, you must supply
  989. *--                a parameter for each option below.
  990. *-- Written for..: dBASE IV, 1.5
  991. *-- Rev. History.: None
  992. *-- Calls........: RECOLOR             Procedure in PROC.PRG
  993. *--                COLORBRK()          Function in PROC.PRG
  994. *-- Called by....: Any
  995. *-- Usage........: ?VPICK(<nRow>,<nCol>,"<cOptions>","<cTitle>","<cMessage>",;
  996. *--                 <lShadow>,<cColor>)
  997. *-- Example......: cHow = VPick(12,15,"~BorBBS~Lastname",;
  998. *--                            "How do you want the data sorted?","Choose one",;
  999. *--                            "&clWind1")
  1000. *-- Returns......: First letter of bar selected, or null if <Esc>.
  1001. *-- Parameters...: nRow     = is a numeric value for the top row of the popup.
  1002. *--                nCol     = is a numeric value for the left column.
  1003. *--                cOptions = is a string of options with each preceded by
  1004. *--                        '~', e.g. "~Screen~Printer~Text File~Return to Menu"
  1005. *--                cTitle   = is an optional title, used for the popup heading
  1006. *--                cMessage = is an optional message string for when the popup 
  1007. *--                           is activated on the screen.
  1008. *--                lShadow  = is a logical value indicating whether or not a 
  1009. *--                           shadow is to be placed under the popup.
  1010. *--                cColor   = Colors to be used ... (uses format:
  1011. *--                           "<Unselected Text>,<SelectedText>,<Border>" where
  1012. *--                           each part above is: <Foreground/Background>, i.e,:
  1013. *--                           "rg+/gb,w+/b,rg+/gb" to get unselected in yellow
  1014. *--                           on Cyan, selected in bright white on blue, and
  1015. *--                           border/box in yellow on cyan.)
  1016. *-------------------------------------------------------------------------------
  1017.     
  1018.     parameters nRow,nCol,cOptions,cTitle,cMessage,lShadow,cColor
  1019.     private nRow,nCol,cOptions,cTitle,cMessage,lShadow,cCurColor,cBox,cTitles,;
  1020.         cTempCol
  1021.     
  1022.     *-- get number of parameters, and a few setup steps ...
  1023.     if val(right(version(),3)) > 1.1
  1024.        nParameters = pcount()
  1025.     else
  1026.         nParameters = 7
  1027.     endif
  1028.    nCount = 0
  1029.    cReturn = ""
  1030.    cOptions = trim(cOptions)
  1031.    cDispMesg = ""
  1032.  
  1033.     *-- save current colors
  1034.     cCurColor = set("ATTRIBUTES")
  1035.     *-- set new colors
  1036.     cTempCol = colorbrk(cColor,1)
  1037.     set color of message to &cTempCol
  1038.     cTempCol = colorbrk(cColor,2)
  1039.     set color of highlight to &cTempCol
  1040.     cTempCol = colorbrk(cColor,3)
  1041.     set color of box to &cTempCol
  1042.     
  1043.    *-- if number of parameters greater/equal to 5, we may have a message
  1044.    *-- at the bottom of the screen ...
  1045.    if nParameters >= 5
  1046.       if len(cMessage) > 0
  1047.          cDispMesg = "MESSAGE "+"'"+cMessage+"'"
  1048.       endif
  1049.    endif
  1050.    *-- define the popup
  1051.    define popup pPickList from nRow,nCol &cDispMesg.
  1052.    nMessage1 = 0
  1053.    *-- if we have 4 or more parameters, one of them is the title ...
  1054.    *-- this requires that the first two bars of the menu be skipped ...
  1055.    if nParameters >= 4
  1056.       if len(cTitle) > 0
  1057.          cTitle = " "+cTitle+" "
  1058.          nMessage1 = len(cTitle)
  1059.          nCount = 2
  1060.       endif
  1061.    endif
  1062.  
  1063.    *-- now we start parsing the options for the menu. These must have
  1064.    *-- a tilde between each, so we look for the first one, and then
  1065.    *-- look again to see if there's another after that.
  1066.  
  1067.    nPos1 = at("~",cOptions)                        && Look for first tilde
  1068.    do while (len(cOptions) > 0) .and. (nPos1 > 0)  && parsing loop ...
  1069.       if nPos1 > 0
  1070.          cSub = substr(cOptions,nPos1+1,len(cOptions)-nPos1)
  1071.          nPos2 = at("~",cSub)
  1072.          if nPos2 = 0
  1073.             nPos2 = len(cSub)
  1074.          else
  1075.             nPos2 = nPos2 - 1
  1076.          endif
  1077.          cOptString = " "+left(cSub,nPos2)+" "
  1078.          if len(cOptString) > nMessage1
  1079.             nMessage1 = len(cOptString)
  1080.          endif
  1081.          *-- define the actual 'bar' of the menu/picklist ...
  1082.          nCount = nCount + 1
  1083.          define bar nCount of pPickList prompt cOptString
  1084.          cOptions = cSub
  1085.       endif
  1086.       nPos1 = at("~",cOptions)
  1087.    enddo  && end of parsing loop
  1088.  
  1089.    *-- now we deal with defining the actual picklist ...
  1090.    if nCount > 0             && if we have something to put in the list ...
  1091.       if nParameters >= 4    && if we have a title for the top ...
  1092.          if len(cTitle) > 0
  1093.             if len(cTitle) < nMessage1
  1094.                cTitle = trim(ltrim(cTitle))
  1095.                cTitle = space((nMessage1-len(cTitle)) / 2) + cTitle
  1096.             endif
  1097.             define bar 1 of pPickList prompt cTitle skip
  1098.             define bar 2 of pPickList prompt replicate(chr(196),nMessage1) skip
  1099.          endif
  1100.       endif
  1101.       *-- define what to do when a choice is made ...
  1102.       on selection popup pPickList deactivate popup
  1103.       *-- if we have a shadow, let's save screen and do the shadow
  1104.       *-- before popping up the picklist
  1105.         if nParameters => 6
  1106.           if lShadow
  1107.              save screen to sPickScr
  1108.              @ nRow+1,nCol+2 fill to nRow+nCount+2,nCol+nMessage1+3 color w/n
  1109.           endif
  1110.         else
  1111.             lShadow = .f.
  1112.         endif
  1113.       *-- there we are ...
  1114.       activate popup pPickList
  1115.  
  1116.       *-- cleanup
  1117.       if lShadow
  1118.         restore screen from sPickScr
  1119.         release screen sPickScr
  1120.       endif
  1121.  
  1122.       *-- deal with what to 'return' ...
  1123.       if lastkey() = 27
  1124.          cReturn = ""
  1125.       else
  1126.          cReturn = substr(prompt(),2,1)
  1127.       endif
  1128.  
  1129.    endif && nCount > 0
  1130.  
  1131.     *-- we're done with it ... return it back to the electronic byte storage
  1132.     *-- bins ... 
  1133.    release popup pPickList
  1134.     *-- reset colors ...
  1135.     do ReColor with cCurColor
  1136.  
  1137. RETURN cReturn
  1138. *-- EoF: VPick()
  1139.  
  1140. *===============================================================================
  1141. * STRING Manipulation. Most of these are in the library file:  STRINGS.PRG
  1142. * The ones here are common to a lot of apps and functions, and are here so
  1143. * that the library STRINGS.PRG need not be called.
  1144. *===============================================================================
  1145.  
  1146. FUNCTION AllTrim
  1147. *-------------------------------------------------------------------------------
  1148. *-- Programmer..: Phil Steele (from PCSDEMO.PRG -- Public Domain)
  1149. *-- Date........: 5/23/1991
  1150. *-- Notes.......: Complete trims edges of field (left and right)
  1151. *-- Written for.: dBASE IV, 1.1
  1152. *-- Rev. History: None
  1153. *-- Calls.......: None
  1154. *-- Called by...: Any
  1155. *-- Usage.......: alltrim(<cString>)
  1156. *-- Example.....: ? alltrim("  Test String  ") 
  1157. *-- Returns.....: Trimmed string, i.e.:"Test String"
  1158. *-- Parameters..: cString = string to be trimmed
  1159. *-------------------------------------------------------------------------------
  1160.     
  1161.     parameters cString
  1162.     
  1163. RETURN ltrim(rtrim(cString))
  1164. *-- EoF: AllTrim()
  1165.  
  1166. FUNCTION State
  1167. *-------------------------------------------------------------------------------
  1168. *-- Programmer..: David G. Franknbach (FRNKNBCH)
  1169. *-- Date........: 04/22/1992
  1170. *-- Notes.......: Validation of state codes -- used to ensure that a user
  1171. *--               doing data entry will enter the proper codes. Added a few
  1172. *--               US Territory codes as well (Puerto Rico, etc.)
  1173. *-- Written for.: dBASE IV, 1.1
  1174. *-- Rev. History: 12/02/1991
  1175. *--               03/11/1992 -- Modified by Ken Mayer (KENMAYER) to handle
  1176. *--               the extra US Territories, and to ensure that the data is
  1177. *--               at least temporarily in upper case when doing the check ...
  1178. *--               04/22/1992 -- Modified by Jay Parsons (JPARSONS) to shorten
  1179. *--               (simplify) the routine by removing the cSTATE2 memvar.
  1180. *-- Calls.......: None
  1181. *-- Called by...: None
  1182. *-- Usage.......: STATE(<cState>)
  1183. *-- Example.....: @5,10 get cState valid required state(cState);
  1184. *--                     error chr(7)+"This is not a valid state code!"
  1185. *-- Returns.....: Logical (.t. if found, .f. otherwise)
  1186. *-- Parameters..: cState = state code to be checked ....
  1187. *-------------------------------------------------------------------------------
  1188.  
  1189.     parameters cState
  1190.     
  1191.     cStateList = "AL|AK|AZ|AR|CA|CO|CT|DE|DC|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|"+;
  1192.                  "ME|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|"+;
  1193.                  "PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY|PR|AS|GU|CM|TT|VI|  "
  1194.     lOK = upper(cState) $ cStateList
  1195.  
  1196. RETURN lOK
  1197. *-- EoF: State()
  1198.  
  1199. *===============================================================================
  1200. *  DATE HANDLING ROUTINES -- Most of these are now in the library file: 
  1201. *  DATES.PRG (included with this version of PROC). However, a few are below,
  1202. *  as they have become 'standard' routines in many of my systems.
  1203. *===============================================================================
  1204.  
  1205. FUNCTION DateText
  1206. *-------------------------------------------------------------------------------
  1207. *-- Programmer..: Miriam Liskin
  1208. *-- Date........: 05/23/1991
  1209. *-- Notes.......: Display date in format Month, day year (e.g., July 1,1991)
  1210. *-- Written for.: dBASE IV, 1.1
  1211. *-- Rev. History: None
  1212. *-- Calls.......: None
  1213. *-- Called by...: Any
  1214. *-- Usage.......: DateText(<dDate>) 
  1215. *-- Example.....: ? datetext(date())
  1216. *-- Returns.....: July 1, 1991
  1217. *-- Parameters..: dDate = date to be converted
  1218. *-------------------------------------------------------------------------------
  1219.  
  1220.     parameters dDate
  1221.     
  1222. RETURN CMONTH(dDate)+" "+ltrim(str(day(dDate),2))+", "+str(year(dDate),4)
  1223. *-- EoF: DateText()
  1224.  
  1225. FUNCTION DateText2
  1226. *-------------------------------------------------------------------------------
  1227. *-- Programmer..: Miriam Liskin
  1228. *-- Date........: 05/23/1991
  1229. *-- Notes.......: Display date in format day-of-week, Month day, year
  1230. *-- Written for.: dBASE IV, 1.1
  1231. *-- Rev. History: None
  1232. *-- Calls.......: None
  1233. *-- Called by...: Any
  1234. *-- Usage.......: DateText2(<dDate>)
  1235. *-- Example.....: ? DateText2(date())
  1236. *-- Returns.....: Thursday, July 1, 1991
  1237. *-- Parameters..: dDate = date to be converted
  1238. *-------------------------------------------------------------------------------
  1239.  
  1240.     parameters dDate
  1241.     
  1242. RETURN CDOW(dDate)+", "+cmonth(dDate)+" "+;
  1243.        ltrim(str(day(dDate),2))+", "+str(year(dDate),4)
  1244. *-- EoF: DateText2()
  1245.  
  1246. *===============================================================================
  1247. * FIELD HANDLING ROUTINES -- Unique searches, string manipulation ...
  1248. * The ones left in PROC.PRG are the more commonly used ones. Anything else is
  1249. * in the library file: FIELDS.PRG.
  1250. *===============================================================================
  1251.  
  1252. FUNCTION IsUnique
  1253. *-------------------------------------------------------------------------------
  1254. *-- Programmer..: Clinton L. Warren (VBCES)
  1255. *-- Date........: 04/28/1992
  1256. *-- Notes.......: Checks to see if an index key already exists in the current
  1257. *--               selected database. This function was inspired by Tom
  1258. *--               Woodward's Chk4Dup UDF.
  1259. *-- Written for.: dBASE IV, 1.1
  1260. *-- Rev. History: May 15, 1991 Version 1.1  Added check for zero record database
  1261. *--               May  7, 1991 Version 1.0  Initial 'release'.
  1262. *--               04/28/1992 -- modified for dBASE IV, 1.5 due to 'new'
  1263. *--               behavior (see READ.ME that comes with 1.5). Should function
  1264. *--               fine with 1.1 and 1.0. This change from David Love (DAVIDLOVE).
  1265. *--               NOTE: NEW PARAMETER
  1266. *-- Calls.......: None
  1267. *-- Called by...: Any
  1268. *-- Usage.......: IsUnique(<xValue>,"<cOrder>","<cField>")
  1269. *-- Example.....: @5,5 SAY "SSN: " GET SSN PICTURE "999-99-9999";
  1270. *--                  valid required IsUnique(SSN, "SSN", "SSN");
  1271. *--                  message "Enter a new SSN";
  1272. *--                  error chr(7)+"SSN must be unique!"
  1273. *-- Returns.....: .T./.F.
  1274. *-- Parameters..: xValue = Value (any non-memo type) to check for uniqueness
  1275. *--               cOrder = MDX Tag used to order the database. Must be set for
  1276. *--                        field being checked.
  1277. *--               cField = field name for 'get'.
  1278. *-------------------------------------------------------------------------------
  1279.     
  1280.     parameters xValue, cOrder, cField
  1281.     private nRecNo, nRecCnt, cSetNear, cSetDel, lIsDeleted, cSetOrder
  1282.     private lIsUnique
  1283.     
  1284.     nRecNo = recno()           && store current record number
  1285.     nRecCnt = reccount()       && count records in database
  1286.     
  1287.     if nRecCnt = 0             && empty database, cValue MUST be unique
  1288.        return .t.
  1289.     endif
  1290.     
  1291.     cSetNear = set('NEAR')     && store status of NEAR flag
  1292.     set near off               && set it off
  1293.     cSetDel = set('DELETE')    && store status of DELETE
  1294.     set delete on              && Delete must be ON for this to work
  1295.     lIsDeleted = deleted()     && is current record deleted?
  1296.     delete                     && set delete flag for current record
  1297.     cSetOrder = order()        && store current MDX tag
  1298.     set order to (cOrder)      && set tag to that sent to function
  1299.     
  1300.     if seek(xValue)            && does it exist already?
  1301.        lIsUnique = .f.         &&   if so, it's not unique
  1302.     else                       && otherwise,
  1303.        lIsUnique = .t.         &&   it is.
  1304.     endif
  1305.    
  1306.    set order to (cSetOrder)   && restore changed settings to original settings
  1307.    set delete &cSetDel
  1308.    set near &cSetNear
  1309.    
  1310.    if nRecNo > nRecCnt        && if called during an append
  1311.       go bottom               && goto the bottom of the database,
  1312.       skip 1                  &&   plus one record (the new one)
  1313.       if lIsUnique            && this is the new part ...
  1314.          replace &cField with xValue
  1315.       endif
  1316.    else
  1317.       go nRecNo               && otherwise, goto the current record number
  1318.    endif
  1319.  
  1320.    if .not. lIsDeleted        && was record 'deleted' before?
  1321.       recall                  && if not, undelete it ... (turn flag off)
  1322.    endif 
  1323.  
  1324. RETURN (lIsUnique)
  1325. *-- EoF: IsUnique()
  1326.  
  1327. FUNCTION MemoPagr
  1328. *-------------------------------------------------------------------------------
  1329. *-- Programmer..: Martin Leon (HMAN - ATBBS/Borland BBS)
  1330. *-- Date........: 10/28/91
  1331. *-- Notes.......: Used to display a memo on screen, allowing user to scroll
  1332. *--               memo at will.
  1333. *-- Written for.: dBASE IV, 1.1
  1334. *-- Rev. History: None
  1335. *-- Calls.......: None
  1336. *-- Called by...: Any
  1337. *-- Usage.......: ?MemoPagr(<cMemo>,<ULRow>,<ULCol>,<BRRow>,<BRCol>)
  1338. *-- Example.....: ?MemoPagr(MoreData,10,20,20,65)
  1339. *-- Returns.....: .F.
  1340. *-- Parameters..: cMemo   = name of memo field
  1341. *--               nULRow  = upper left row position
  1342. *--               nULCol  = upper left column position
  1343. *--               nBRRow  = bottom right row position
  1344. *--               nBRCol  = bottom right column position
  1345. *-------------------------------------------------------------------------------
  1346.     
  1347.     PARAMETER cMemo, nULRow, nULCol, nBRRow, nBRCol
  1348.     private cCursor, nEsc, nPgDn, nPgUp, nUp, nDn, nNumLines,nLines,nKey
  1349.     private nAtLine,nAtRow
  1350.     
  1351.     *-- set environment
  1352.     set memowidth to nBRCol - nULCol - 1
  1353.     cCursor = set( "CURSOR" )
  1354.     set cursor off
  1355.     
  1356.     *-- define a few keys
  1357.     nEsc  = 27
  1358.     nPgDn = 3
  1359.     nPgUp = 18
  1360.     nUp   = 5
  1361.     nDn   = 24
  1362.     
  1363.     *-- determine size of window
  1364.     nNumLines = memlines(&cMemo)
  1365.     nLines = nBRRow - nULRow - 1
  1366.     *-- save the screen, so we can restore it
  1367.     save screen to sTmp
  1368.     @ nULRow+1, nULCol+1 clear to nBRRow+1, nBRCol+1
  1369.     @ nULRow+1, nULCol+1 fill to nBRRow+1, nBRCol+1 color B/N
  1370.     @ nULRow+1, nULCol+1 fill to nBRRow-1, nBRCol-1 color RG+/B
  1371.     @ nULRow, nULCol to nBRRow, nBRCol double color RG+/B
  1372.     
  1373.     *-- deal with a blank memo ...
  1374.     if nNumLines = 0
  1375.        @ nULRow + 1, nULCol + 1 SAY ;
  1376.           "Blank Memo.  Press any key to continue..." color RG+/B
  1377.        nKey = inkey(0)
  1378.         *-- reset the whole thing
  1379.        restore screen from sTmp
  1380.        release screen sTmp
  1381.        set cursor &cCursor
  1382.        RETURN .F.
  1383.     endif
  1384.     
  1385.     nAtLine = 1
  1386.     nAtRow = 1
  1387.     do while nAtLine <= nNumLines
  1388.        *-- Show one window full
  1389.        do while nAtRow <= nLines .and. nAtLine <= nNumLines
  1390.           @ nULRow+nAtRow, nULCol + 1 say ;
  1391.              mline( &cMemo, nAtLine ) color RG+/B
  1392.           nAtLine = nAtLine + 1
  1393.           nAtRow = nAtRow + 1
  1394.        enddo
  1395.    
  1396.        *-- If at last line of memo...
  1397.        if nAtLine > nNumLines
  1398.           *-- If memo is shorter than one page, put box character in
  1399.           *-- bottom left corner of box, otherwise, put an up arrow
  1400.           *-- symbol there.
  1401.           @ nBRRow - 1, nBRCol SAY ;
  1402.          iif( nNumLines <= nLines, chr(186), chr(24)) color W+/B
  1403.           do while .T.
  1404.              nKey = inkey(0)
  1405.              *-- If memo is shorter than one page, only allow Esc key
  1406.              if nNumLines <= nLines
  1407.                 if nKey = nEsc
  1408.                    exit
  1409.                 endif
  1410.              *-- Otherwise, allow Esc or PgUp keys
  1411.              else
  1412.                 if nKey = nEsc .or. nKey = nPgUp .or. nKey = nUp
  1413.                    exit
  1414.                 endif
  1415.              endif
  1416.              ?? chr(7)
  1417.           enddo
  1418.           if nKey = nEsc
  1419.              restore screen from sTmp
  1420.              release screen sTmp
  1421.              set cursor &cCursor
  1422.              RETURN .F.
  1423.           endif
  1424.           @ nULRow+1, nULCol+1 clear to nBRRow-1, nBRCol-1
  1425.           @ nULRow+1, nULCol+1 fill to nBRRow-1, nBRCol-1 ;
  1426.              color RG+/B
  1427.           nAtLine = nAtLine -  nAtRow - nLines + 1
  1428.           nAtLine = iif( nAtLine < 1, 1, nAtLine )
  1429.           nAtRow = 1
  1430.           loop
  1431.        endif
  1432.    
  1433.        *-- Not at end of memo yet...
  1434.        *-- If on first page, show down arrow only, otherwise show
  1435.        *-- up/down arrow on border of box.
  1436.        @ nBRRow - 1, nBRCol say ;
  1437.            iif( nAtLine - nLines = 1, chr(25), chr(18)) color W+/B
  1438.        do while .T.
  1439.           nKey = inkey(0)
  1440.           *-- If this is the first page of the memo on screen...
  1441.           if nAtLine - nLines = 1
  1442.               *-- Only honor PgDn, up cursor, and Esc keys
  1443.              if nKey = nPgDn .or. nKey = nDn .or. nKey = nEsc
  1444.                 exit
  1445.              endif
  1446.           *-- otherwise honor PgUp and up cursor as well key as well
  1447.           else 
  1448.              if nKey = nPgUp .or. nKey = nUp .or. nKey = nPgDn .or. ;
  1449.                     nKey = nDn .or. nKey = nEsc
  1450.                 exit
  1451.              endif
  1452.           endif
  1453.           ?? chr(7)
  1454.        enddo
  1455.        do case
  1456.           case nKey = nEsc
  1457.              restore screen from sTmp
  1458.              release screen sTmp
  1459.              set cursor &cCursor
  1460.              RETURN .F.
  1461.           case nKey = nPgUp .or. nKey = nUp
  1462.              @ nULRow+1, nULCol+1 clear to nBRRow-1, nBRCol-1
  1463.              @ nULRow+1, nULCol+1 fill to nBRRow-1, nBRCol-1 ;
  1464.                 color RG+/B
  1465.              nAtLine = (nAtLine - (2 * nLines))
  1466.              nAtLine = IIF( nAtLine < 1, 1, nAtLine )
  1467.              nAtRow = 1
  1468.              loop
  1469.           case nKey = nPgDn .or. nKey = nDn
  1470.              @ nULRow+1, nULCol+1 clear to nBRRow-1, nBRCol-1
  1471.              @ nULRow+1, nULCol+1 fill to nBRRow-1, nBRCol-1 ;
  1472.                 color RG+/B
  1473.              nAtRow = 1
  1474.              loop
  1475.        endcase
  1476.     enddo
  1477.  
  1478. RETURN .F.
  1479. *-- EoF: MemoPagr()
  1480.  
  1481. *===============================================================================
  1482. * MISC ROUTINES -- Ones that don't fit into other categories, quite ... but
  1483. * are none-the-less very useful ... many of these routines have been placed
  1484. * in the library file:  MISC.PRG.
  1485. *===============================================================================
  1486.  
  1487. FUNCTION IsMouse
  1488. *-------------------------------------------------------------------------------
  1489. *-- Programmer..: Ken Mayer (KENMAYER)
  1490. *-- Date........: 06/18/1992
  1491. *-- Notes.......: This is used to determine the presence of a mouse driver.
  1492. *--               Returns a .t. if a mouse driver is detected, a .f. otherwise.
  1493. *--               This routine will turn the mouse off, automatically. This
  1494. *--               can be used to detect a mouse, and turn it off, as well
  1495. *--               as to set a memvar to determine the current mouse state.
  1496. *--               For example, after running this routine, the mouse will be
  1497. *--               off (if there's a driver).
  1498. *--               ******************************
  1499. *--               **** REQUIRES JPMOUSE.BIN ****
  1500. *--               ******************************
  1501. *-- Written for.: dBASE IV, 1.5
  1502. *-- Rev. History: None
  1503. *-- Calls.......: None
  1504. *-- Called by...: Any
  1505. *-- Usage.......: IsMouse()
  1506. *-- Example.....: ?IsMouse()
  1507. *-- Returns.....: Logical
  1508. *-- Parameters..: None
  1509. *-------------------------------------------------------------------------------
  1510.  
  1511.     private cRetVal, lIsMouse, X
  1512.     
  1513.     Load JPMOUSE.BIN
  1514.     cRetVal = call("JPMOUSE","?")
  1515.     lIsMouse = iif(cRetVal="T",.t.,.f.)
  1516.     if lIsMouse
  1517.         x = call("JPMOUSE","H")
  1518.     endif
  1519.     release module JPMOUSE
  1520.  
  1521. RETURN lIsMouse
  1522. *-- EoF: IsMouse()
  1523.  
  1524. PROCEDURE SetMouse
  1525. *-------------------------------------------------------------------------------
  1526. *-- Programmer..: Ken Mayer (KENMAYER)
  1527. *-- Date........: 06/18/1992
  1528. *-- Notes.......: This is used to determine the presence of a mouse driver,
  1529. *--               and/or turn the mouse cursor off in dBASE IV, 1.5
  1530. *--               ******************************
  1531. *--               **** Requires JPMOUSE.BIN ****
  1532. *--               ******************************
  1533. *-- Written for.: dBASE IV, 1.5
  1534. *-- Rev. History: None
  1535. *-- Calls.......: None
  1536. *-- Called by...: Any
  1537. *-- Usage.......: Do SetMouse with <c_Mouse>
  1538. *-- Example.....: PUBLIC c_Mouse
  1539. *--               x=ismouse()  && function in MISC.PRG
  1540. *--               store "OFF" to c_Mouse  && after calling IsMouse() it's 'Off'
  1541. *--               ON KEY LABEL Alt-M DO SetMouse
  1542. *-- Returns.....: .T.
  1543. *-- Parameters..: c_Mouse = A GLOBAL memory variable -- this can/will be changed
  1544. *--                         by this procedure to the opposite scenario when the
  1545. *--                         routine is called. The concept here is to switch
  1546. *--                         the mouse on and/or off if there's a mouse driver.
  1547. *--                This memvar should be set to the current status of the mouse-
  1548. *--                if on, it should hold "ON" in it ...
  1549. *-------------------------------------------------------------------------------
  1550.  
  1551.     private X
  1552.     
  1553.     if type("C_MOUSE") # "C"         && if c_Mouse has not been defined as
  1554.         return                        &&   a character field, return
  1555.     endif
  1556.     
  1557.     load JPMOUSE.BIN                && load the module
  1558.     
  1559.     *-- if the mouse is off, we're going to set it on ("S"), if on, we're
  1560.     *-- going to set it off "H")
  1561.     cSetMouse = iif(upper(c_Mouse) = "OFF","S","H") 
  1562.     x=call("JPMOUSE",cSetMouse)      
  1563.     
  1564.     release module JPMOUSE           && remove from memory
  1565.     
  1566.     *-- if c_Mouse was 'off' we are setting it 'on', and vice versa
  1567.     c_Mouse = iif(upper(c_Mouse) = "OFF","ON","OFF") && change state of c_Mouse
  1568.  
  1569. RETURN
  1570. *-- EoP: SetMouse
  1571.  
  1572. FUNCTION IsBlank
  1573. *-------------------------------------------------------------------------------
  1574. *-- Programmer..: Jerry Wightman (WIGHTMAN)
  1575. *-- Date........: ?
  1576. *-- Notes.......: Used to check whether a memory variable in dBASE contains
  1577. *--               anything, based on type of field. (Pulled from BORBBS)
  1578. *--               NOTE: In release 1.5, replace all calls to EMPTY() with
  1579. *--               the new:  ISBLANK() function. This will be faster.
  1580. *--               Renamed for use here to ISBLANK(), for compatibilities' sake.
  1581. *-- Written for.: dBASE IV, 1.1
  1582. *-- Rev. History: None
  1583. *-- Calls.......: None
  1584. *-- Called by...: Any
  1585. *-- Usage.......: IsBlank(<cFld>)
  1586. *-- Example.....: @5,10 say "Enter date: " get bDate;
  1587. *--                         valid required .not. IsBlank(bDate);
  1588. *--                         error chr(7)+"** Date cannot be Empty! **"
  1589. *-- Returns.....: Logical (.t./.f.)
  1590. *-- Parameters..: cFld  =  Field/Memvar/Expression to check for "Emptiness"
  1591. *-------------------------------------------------------------------------------
  1592.  
  1593.     PARAMETERS cFld       && may be memory variable or database field name
  1594.     private cTalk, lReturn
  1595.  
  1596.     cTalk = SET("TALK")
  1597.  
  1598.     lReturn = .F.      &&  FALSE means:  variable is NOT empty
  1599.  
  1600.     do case
  1601.        case type( "cFld" ) = "C"
  1602.           if len( ltrim(rtrim( cFld )) ) = 0
  1603.              lReturn = .T.
  1604.             endif
  1605.  
  1606.         case type( "cFld" ) = "N" .or. type( "cFld" ) = "F"
  1607.             if cFld = 0
  1608.                 lReturn = .T.
  1609.             endif
  1610.  
  1611.         case type( "cFld" ) = "L"
  1612.             lReturn = .F.  && Can't check logical fields
  1613.  
  1614.         case type( "cFld" ) = "D"
  1615.             if cFld = {}
  1616.                 lReturn = .T.
  1617.             endif
  1618.  
  1619.         case type( "cFld" ) = "M"
  1620.             if len( cFld ) = 0
  1621.                                 lReturn = .T.
  1622.             endif
  1623.  
  1624.         otherwise   && TYPE = "U"
  1625.             lReturn = .T.
  1626.  
  1627.     endcase
  1628.  
  1629.     set talk &cTalk
  1630.     
  1631. RETURN lReturn
  1632. *-- EoF: IsBlank()
  1633.  
  1634. *===============================================================================
  1635. *-- End of Procedure File -- PROC.PRG
  1636. *===============================================================================
  1637.